<template>
  <el-container class="home-container">
    <el-header>
      <div class="divimg">
        <img class="logoimg" src="../assets/logo.png" alt="" />
        <span class="spanimg">人才管理系统</span>
      </div>
      <el-button type="info" @click="logout">退出</el-button>
    </el-header>
    <el-container>
      <el-aside :width="isCollapse?'64px':'240px'">
        <div  class="toggle-button" @click="toggle">|||</div>
        <el-menu background-color="#3C3C3C" text-color="#fff" active-text-color="#409EFF" unique-opened="" :collapse = "isCollapse" :collapse-transition="false" router :default-active="$route.path">
          
          <!-- 一级 -->
          <el-submenu :index="item.id+''" v-for="item in menulist" :key="item.id">
              <!-- 一级菜单模板 -->
            <template slot="title">
              <i :class="iconsObj[item.id]"></i>
              <span>{{item.authName}}</span>
            </template>
            <!-- 二级 -->
            <el-menu-item :index="'/'+subItem.path" v-for="subItem in item.children" :key = "subItem.id">
                <!-- 二级菜单模板 -->
                <template slot="title">
                <i class="el-icon-location"></i>
                <span>{{subItem.authName}}</span>
                </template>
            </el-menu-item>
          </el-submenu>
          
        </el-menu>
      </el-aside>
      <el-main>
        <router-view>

        </router-view>
      </el-main>
    </el-container>
  </el-container>
</template>

<script>
export default {
  data() {
    return {
      menulist: [
        {
          authName:'员工信息',
          id:125,
          path:null,
          children:[
            {authName:'员工列表',
            id:null,
            path:'users'}
          ]
        },
        {
          authName:'待处理',
          id:102,
          path:null,
          children:[
            {
              authName:'信息审核',
              path:null,
              path:'check'
            }
        ]
        }
      ],
      iconsObj: {
        '125': 'el-icon-user',
        '103': 'el-icon-set-up',
        '101': 'el-icon-truck',
        '102': 'el-icon-document',
        '145': 'el-icon-s-data'
      },
      isCollapse: true ,
    }
    
  },
  created() {
    //this.getMenuList()
  },
  methods: {
    logout() {
      window.sessionStorage.clear();
      this.$router.push("/login");
    },
    // async getMenuList() {
    //   const {data:res} = await this.$http.get('menus');
    //   if(res.meta.status!==200) return this.$message.error("请求失败")
    //   this.menulist = res.data;
    // },
    toggle() {
      this.isCollapse = !this.isCollapse;
    }
  },
};
</script>

<style Lang="less" scoped>
.home-container {
  height: 100%;
}
.el-header {
  background-color: 	#272727;
  display: flex;
  justify-content: space-between;
  padding-left: 0;
  align-items: center;
  color: white;
  font-size: 20px;
}

.el-aside {
  background-color:#3C3C3C;
}
.el-aside .el-menu {
  border-right: none;
}
.toggle-button {
  background-color: rgba(124, 122, 122, 0.137);
  font-size: 10px;
  line-height: 24px;
  color: white;
  text-align: center ;
  letter-spacing: 0.2em;
  cursor: pointer;
}

.el-main {
  background-color: gainsboro;
}
.divimg {
  display: flex;
  align-items: center;
}
.spanimg {
  margin-left: 10px;
}

.logoimg {
  width: 40px;
  border: 2px solid white;
  background-color: white;
  border-radius: 50%;
}

</style>